<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>亚马逊 - 留言</title>
<link href="${pageContext.request.contextPath}/css/index.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/adv.css" rel="stylesheet" type="text/css" />
<script src="${pageContext.request.contextPath}/scripts/jquery-2.1.0.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/scripts/adv.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/function.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/index.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/comment.js"></script>
	<%--ADD New Comment--%>
	<script>
		$(function () {
			ShowA(1,3);
			addNew();

		});


          function addNew(){
			  var $guestname,$title,$content,$sumbit;
          	$guestname=$("#guestname");
			  $title=$("#title");
			  $content=$("#content");
			  $sumbit=$("#sumbit");
			  $sumbit.click(function () {
				  $.post("${pageContext.request.contextPath}/comment?param=addNew",{
					  "guestName":$guestname.val(),
					  "guestTitle":$title.val(),
					  "guestContent":$content.val(),
					  "submit":$sumbit.val()
				  },function (data) {
					  if(data.success!=true){
						  alert("留言失败")
					  }else{
						  alert("留言成功");
						  window.location="${pageContext.request.contextPath}/guestbook.jsp";
					  }

				  },"json");
			  })
		  }

/*---------------------------------------------ADD NEW COMMENT FINISH---------------------------------------------*/


		function ShowA(pageNo, pageSize){
			$.post("${pageContext.request.contextPath}/comment?param=comm",{
						// "param":"comm",
						"pageNo": pageNo,
						"pageSize": pageSize
					}
					,function (data) {
                   var $ul=$(".guestbook>ul");
                    $ul.empty();
						for (var i = 0; i < data.comme.list2.length; i++) {
							var $li=$("<li></li>");
							var $dl=$("<dl></dl>");
							$ul.append($li);
							$li.append($dl);
							var $dt=$("<dt>内容:"+data.comme.list2[i].content+"</dt>");
							$dl.append($dt);
							var $dd=$("<dd class='author'><span>作者："+data.comme.list2[i].nick_name+"</span></dd>");
							$dl.append($dd);
							var $dd1=$("<dd>回复:"+data.comme.list2[i].reply+"</dd>");
							$dl.append($dd1);
							var $dd2=$("<dd>"+"回复时间"+data.comme.list2[i].reply_time+"</dd>");
							$dl.append($dd2);
						}
						/*-------------------------------------------------------------------------------------------------------*/
						$a = $(".page>a");
						$a.eq(0).attr("href", "javascript:ShowA('" + 1 + "','" + pageSize + "')");
						$a.eq(1).attr("href", "javascript:ShowA('" + data.comme.prePage + "','" + pageSize + "')");
						$a.eq(2).attr("href", "javascript:ShowA('" + data.comme.nextPage + "','" + pageSize + "')");
						$a.eq(3).attr("href", "javascript:ShowA('" + data.comme.totalPages + "','" + pageSize + "')");
						$span = $(".page>span");
						$span.eq(0).html(data.comme.pageNo);
						$span.eq(1).html(data.comme.totalPages);
					}, "json");
		}
	</script>

</head>
<body>
<%@ include file="index_top.jsp"  %>
<div id="position" class="wrap">
	您现在的位置：<a href="${pageContext.request.contextPath}/index.jsp">亚马逊</a> &gt; 在线留言
</div>
<div id="main" class="wrap">
	<div class="lefter">
		<%@ include file="index_product_sort.jsp" %>
	</div>
	<div class="main">
		<div class="guestbook">
			<h2>全部留言</h2>
			<ul>

			</ul>
			<!--分页栏 -->
			<div class="page" align="center" style="margin-top:10px" >
				<a href="#">首页</a>&nbsp;&nbsp;&nbsp;
				<a href="#">上一页</a>&nbsp;&nbsp;
				<a href="#">下一页</a>&nbsp;&nbsp;
				<span></span>/<span></span>&nbsp;&nbsp;
				<a href="#">最后一页</a>
			</div>

			<div class="clear"></div>
			<div class="pager">

				<ul class="clearfix">
				</ul>
			</div>
			
			<div id="reply-box">
				<form  method="post" onsubmit="return commentCheck()">
					<table>
						<tr>
							<td class="field">昵称：</td>
							<td><input class="text" type="text" name="guestName" id="guestname"/></td>
						</tr>
						<tr>
							<td class="field">留言标题：</td>
							<td><input class="text" type="text" name="guestTitle" id="title"/></td>
						</tr>
						<tr>
							<td class="field">留言内容：</td>
							<td><textarea name="guestContent" id="content"></textarea></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td><label class="ui-blue"><input type="button" name="submit" value="提交留言" id="sumbit"/></label></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
<div id="footer">
	Copyright &copy; 2018 上海海文 All Rights Reserved. 京ICP证1000001号
</div>
</body>
</html>
